//
//  CYApplyToViewVC.m
//  CreditAddressBookEE
//
//  Created by LE on 16/2/25.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYApplyToViewVC.h"

#define CYViewWidth CYScreeSize.width - 40

@interface CYApplyToViewVC ()

@property (weak, nonatomic) IBOutlet UILabel *tipLabel;
@property(nonatomic, copy) CYConfirmClicked clicked;
@end

@implementation CYApplyToViewVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.width = CYViewWidth;
    self.view.height = 150;
    self.view.layer.cornerRadius = 5;
    self.view.layer.masksToBounds = YES;
    [self setupTip];
}

- (void)setupTip {
    self.tipLabel.text = self.tip;
    CGSize messageSize = [self.tip sizeWithFont:self.tipLabel.font constrainedToSize:CGSizeMake(CYViewWidth, MAXFLOAT)];
    self.view.height = self.view.height + messageSize.height;
}

- (void)confirmBtnClicked:(CYConfirmClicked)clicked {
    self.clicked = [clicked copy];
}

- (IBAction)confirmBtn:(UIButton *)sender {
    CYWeakObject(wself, self);
    [self dismissViewControllerAnimated:YES completion:^{
        if (wself.clicked) {
            wself.clicked();
            wself.clicked = nil;
        }
    }];
}
- (IBAction)cancelBtn:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
